
#ifndef LATTICE_H
#define LATTICE_H
 
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<fstream>
#include<string>
#include<vector>

//lbe2d
#include "Common.h"

#define Q_DIM 	9

#define c1		(-2)
#define alpha2	(-8)
#define alpha3	(4) //BGK
#define gamma1	(2./3.)
#define gamma2	(18)
#define gamma3	(2./3.)
#define gamma4	(-18) //BGK

using namespace std;

typedef vector<double> vecdouble;
typedef vector<vector<double> > vec2double;
typedef vector<vector<bool> > vec2bool;
typedef vector<vector<vector<double> > > vec3double;

enum momentum {
	iRHO=0, iE, iEPSILON, iJX, iQX, iJY, iQY, iPXX, iPXY
};

class Lattice {
	private:
		vec<int> dim;

		void stream(int i, int j);
		void collide(int i, int j);
		void swapGrids();
		void calcEQ(int i, int j);

	public:
		vec3double f;
		vec3double faux;
		vec3double m;
		//vec2double rho;
		double s[Q_DIM];
		double meq[Q_DIM];
		//vector<vector<vec<double> > > u;
		vec2bool isObstacle;

		Lattice();
		void init(int nX, int nY, double _rho, double se, double sepsilon, double sq, double snu);

		void update();
		void resetGrid(double _rho);

		//seters
		void setU(int i, int j, vec<double> _u, double _rho);

		//geters
		double getPopulation();
		double energy();
		double RMSvelocity();
};

#endif
